package br.com.ac.fatureweb.service;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import br.com.ac.fatureweb.integration.model.OcorrenciaVO;
import br.com.ac.fatureweb.model.carga.Ocorrencia;
import br.com.ac.fatureweb.utilitary.NgcDefaultBean;

@Local
@Named
@Stateless
@SuppressWarnings("all")
public class NgcOcorrenciaBean extends NgcDefaultBean<Ocorrencia> {

	@PersistenceContext
	private EntityManager entityManager;

	@PostConstruct
	void inicialize() {
		setEm(entityManager);
	}

	public List<OcorrenciaVO> listarOcorrencia() {
		Query query = entityManager
				.createQuery("SELECT NEW OcorrenciaVO(codigo, "
						+ " descricao, flgOcorrencia, flgTipoCobranca, emitirConta) "
						+ " FROM Ocorrencia ");

		return query.getResultList();
	}

}
